<?php
global $uctheme_option;

if(is_home()){
	$keywords = $uctheme_option['general']['home_keyword']; //首页描述信息
	$description = $uctheme_option['general']['home_desc'];//首页关键词
	
}elseif(is_single() || is_page() ){
	$description = get_post_meta($post->ID,'_seo_description',true);
	$keywords = get_post_meta($post->ID,'_seo_keywords',true); //获取自定义关键词
	
	if($keywords == ''){
		$aaa=wp_get_post_tags($post->ID);
		$key_arry = array();
		foreach($aaa as $bbb)
		$key_arry[] = $bbb->name;

		$keywords = implode(',',$key_arry);
	}
	
	if($keywords == ''){
		$keywords = $uctheme_option['general']['home_keyword'];
	}
	if($description == ''){
		$description = str_replace("\n","",strip_tags($post->post_content));
		$description = str_replace("\r","",$description);
		$description = str_replace("\t","",$description);
		$description = mb_substr( $description,0,100,'UTF-8');
	}
}elseif( is_tax('mall') ){
	$currentterm = get_queried_object();
	$description = get_term_meta($currentterm->term_id , '_seo_description',true);
	$keywords = get_term_meta($currentterm->term_id , '_seo_keywords',true);
	
	if($description == ''){
		$description = term_description($currentterm->term_id,'mall'); //首页描述信息
	}
	
	if($description == ''){
		$description = $uctheme_option['general']['home_desc']; //首页描述信息
	}
	if($keywords == ''){
		$keywords = $uctheme_option['general']['home_keyword'];//首页关键词
	}
}elseif( is_tax('shop')){
	$currentterm = get_queried_object();
	$description = get_term_meta($currentterm->term_id , '_seo_description',true);
	$keywords = get_term_meta($currentterm->term_id , '_seo_keywords',true);
	
	if($description == ''){
		$description = term_description($currentterm->term_id,'shop'); //首页描述信息
	}
	
	if($description == ''){
		$description = $uctheme_option['general']['home_desc']; //首页描述信息
	}
	if($keywords == ''){
		$keywords = $uctheme_option['general']['home_keyword'];//首页关键词
	}
}elseif( is_tax('detail_tag') ){
	$currentterm = get_queried_object();
	$description = get_term_meta($currentterm->term_id , '_seo_description',true);
	$keywords = get_term_meta($currentterm->term_id , '_seo_keywords',true);
	
	if($description == ''){
		$description = term_description($currentterm->term_id,'detail_tag'); //首页描述信息
	}
	
	if($description == ''){
		$description = $uctheme_option['general']['home_desc']; //首页描述信息
	}
	if($keywords == ''){
		$keywords = $uctheme_option['general']['home_keyword'];//首页关键词
	}
}elseif( is_post_type_archive('detail') ){
	$description = $uctheme_option['general']['home_desc']; //首页描述信息
	$keywords = $uctheme_option['general']['home_keyword'];//首页关键词
}elseif( is_post_type_archive('notice') ){
	$description = $uctheme_option['general']['home_desc']; //首页描述信息
	$keywords = $uctheme_option['general']['home_keyword'];//首页关键词
}elseif( is_category() ){
	$currentterm = get_queried_object();
	$description = get_term_meta($currentterm->term_id , '_seo_description',true);
	$keywords = get_term_meta($currentterm->term_id , '_seo_keywords',true);
	
	if($description == ''){
		$description = category_description($currentterm->term_id); //首页描述信息
	}
	
	if($description == ''){
		$description = $uctheme_option['general']['home_desc']; //首页描述信息
	}
	if($keywords == ''){
		$keywords = $uctheme_option['general']['home_keyword'];//首页关键词
	}
}else{
	$keywords = $uctheme_option['general']['home_keyword']; //首页描述信息
	$description = $uctheme_option['general']['home_desc'];//首页关键词
}
?>